package com.last1mile.dao.ibatis.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.stereotype.Component;

import com.last1mile.dao.BaseSqlMapClientDao;
import com.last1mile.dao.interfaces.StreetDao;
import com.last1mile.pojo.StreetDO;

@Component("streetDao")
public class StreetDaoImpl extends BaseSqlMapClientDao implements StreetDao {
	@SuppressWarnings("unchecked")
	@Override
	public List<StreetDO> selectByStreetUpId(String streetUpId) throws SQLException {
		StreetDO key = new StreetDO();
		key.setStreetUpId(streetUpId);
		List<StreetDO> records = (List<StreetDO>) getSqlMapClientTemplate().queryForList("street.selectByStreetUpId", key);
		return records;
	}
	
	public StreetDO selectByPrimaryKey(Integer id) throws SQLException {
		StreetDO key = new StreetDO();
		key.setId(id);
		StreetDO record = (StreetDO) getSqlMapClientTemplate().queryForObject("street.selectByPrimaryKey",key);
		return record;
	}
	
	@Override
	public StreetDO selectByStreetUpIdAndCnName(String streetUpId, String cnName){
		StreetDO key = new StreetDO();
		key.setStreetUpId(streetUpId);
		key.setCnName(cnName);
		StreetDO record = (StreetDO) getSqlMapClientTemplate().queryForObject("street.selectByDO",key);
		return record;
	}

	public Integer insert(StreetDO record){
		return (Integer) getSqlMapClientTemplate().insert("street.insert",record);
	}

	public int updateByPrimaryKey(StreetDO record) throws SQLException {
		int rows = getSqlMapClientTemplate().update("street.updateByPrimaryKey", record);
		return rows;
	}

	public int updateByPrimaryKeySelective(StreetDO record) throws SQLException {
		int rows = getSqlMapClientTemplate().update("street.updateByPrimaryKeySelective", record);
		return rows;
	}

	

	public int deleteByPrimaryKey(Integer id) throws SQLException {
		StreetDO key = new StreetDO();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete("street.deleteByPrimaryKey", key);
		return rows;
	}

	
	
	

}
